{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 直角机器人\n",
    "在我们进入三角学之前，我想让你熟悉一下你将要在本课中使用的Vehicle类（并让你思考一下一般的运动）。\n",
    "\n",
    "在这个 notebook 中，你将通过填写两种方法来完成一个`Vehicle`类：`drive_forward`和`turn_right`。\n",
    "\n",
    "请注意，此版本的Vehicle类只能朝向4个方向之一：（E）ast、（N）orth、（W）est或（S）outh。 车辆的当前方向存储在其`heading`属性中。\n",
    "\n",
    "如果你已经实现了以下两种方法，则可以在notebook最后一部分运行测试单元格，确保一切按预期运行。\n",
    "\n",
    "### TODO - 执行  `drive_forward` 函数与 `turn_right` 函数\n",
    "**解决方案代码会在下一个notebook中提供给你。**"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "from matplotlib import pyplot as plt\n",
    "\n",
    "class Vehicle:\n",
    "    def __init__(self):\n",
    "        \"\"\"\n",
    "        Creates new vehicle at (0,0) with a heading pointed East.\n",
    "        \"\"\"\n",
    "        self.x       = 0 # meters\n",
    "        self.y       = 0\n",
    "        self.heading = \"E\" # Can be \"N\", \"S\", \"E\", or \"W\"\n",
    "        self.history = []\n",
    "        \n",
    "    # TODO-1 - Implement this function \n",
    "    def drive_forward(self, displacement):\n",
    "        \"\"\"\n",
    "        Updates x and y coordinates of vehicle based on \n",
    "        heading and appends previous (x,y) position to\n",
    "        history.\n",
    "        \"\"\"\n",
    "        \n",
    "        # this line appends the current (x,y) coordinates\n",
    "        # to the vehicle's history. Useful for plotting \n",
    "        # the vehicle's trajectory. You shouldn't need to\n",
    "        # change this line.\n",
    "        self.history.append((self.x, self.y))\n",
    "        \n",
    "        # vehicle currently pointing east...\n",
    "        if   self.heading == \"E\":\n",
    "            self.x += displacement\n",
    "        \n",
    "        # north\n",
    "        elif self.heading == \"N\":\n",
    "            # FILL THIS OUT\n",
    "            pass\n",
    "        \n",
    "        # west\n",
    "        elif self.heading == \"W\":\n",
    "            # FILL THIS OUT\n",
    "            pass\n",
    "        \n",
    "        # south\n",
    "        else:\n",
    "            # FILL THIS OUT\n",
    "            pass\n",
    "        \n",
    "    def turn(self, direction):\n",
    "        if direction == \"L\":\n",
    "            self.turn_left()\n",
    "        elif direction == \"R\":\n",
    "            self.turn_right()\n",
    "        else:\n",
    "            print(\"Error. Direction must be 'L' or 'R'\")\n",
    "            return\n",
    "        \n",
    "    def turn_left(self):\n",
    "        \"\"\"\n",
    "        Updates heading (for a left turn) based on current heading\n",
    "        \"\"\"\n",
    "        next_heading = {\n",
    "            \"N\" : \"W\",\n",
    "            \"W\" : \"S\",\n",
    "            \"S\" : \"E\",\n",
    "            \"E\" : \"N\",\n",
    "        }\n",
    "        self.heading = next_heading[self.heading]\n",
    "        \n",
    "    \n",
    "    # TODO-2 - implement this function\n",
    "    def turn_right(self):\n",
    "        pass\n",
    "    \n",
    "    def show_trajectory(self):\n",
    "        \"\"\"\n",
    "        Creates a scatter plot of vehicle's trajectory.\n",
    "        \"\"\"\n",
    "        X = [p[0] for p in self.history]\n",
    "        Y = [p[1] for p in self.history]\n",
    "        \n",
    "        X.append(self.x)\n",
    "        Y.append(self.y)\n",
    "        \n",
    "        plt.scatter(X,Y)\n",
    "        plt.plot(X,Y)\n",
    "        plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYwAAAD8CAYAAABkbJM/AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMi4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvhp/UCwAAFBJJREFUeJzt3X2QXfV93/H3p5KhQMOzcECCihqFltgtdu6AXaYZGiyQUw+iKR0rQxNlSqIkY5q0bpzCeFI8uEmMndptxowTYQjEJQaG+EFOa8sCzHSSwVgrP/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+sLhpjH31FeSMH2O/ZGq+si4+xmkqq6qqhVVtZLp1/XuqlqQ74Kr6n8BO5Kc2Q1dADw8xpYG+Q7w1iRHdj8XF7CAL9J39t17Dua+99yCkWQN8O+Ai6vq/467n7lU1QNVdVJVrex+16aAt3Q/0yP1mg+M7qLWFUzfJPER4Paqemi8Xc3pPODnmH6nvu+/r/3pcTd1CPlXwC1J7gfOBn5nzP3MqTsSugP4GvAA07/LC+abyUk+BdwLnNndJ+5y5rj33EIwR78fA34E2NL9rv3BWJvszNHrq7PvhXuUJUlaSF7zRxiSpDYGhiSpiYEhSWpiYEiSmhgYkqQmBoYkqYmBIUlqYmBIkpr8P9K69ixMhU0PAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "ename": "AssertionError",
     "evalue": "",
     "output_type": "error",
     "traceback": [
      "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[0;31mAssertionError\u001b[0m                            Traceback (most recent call last)",
      "\u001b[0;32m<ipython-input-5-eca941e0557f>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m()\u001b[0m\n\u001b[1;32m     41\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m     42\u001b[0m \u001b[0;31m# TESTING\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 43\u001b[0;31m \u001b[0;32massert\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mv\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mx\u001b[0m \u001b[0;34m==\u001b[0m \u001b[0;36m5\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m     44\u001b[0m \u001b[0;32massert\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mv\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0my\u001b[0m \u001b[0;34m==\u001b[0m \u001b[0;36m3\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m     45\u001b[0m first_5 = [\n",
      "\u001b[0;31mAssertionError\u001b[0m: "
     ]
    }
   ],
   "source": [
    "# TESTING CODE 1\n",
    "\n",
    "# instantiate vehicle\n",
    "v = Vehicle()\n",
    "\n",
    "# drive in spirals of decreasing size\n",
    "v.drive_forward(8)\n",
    "v.turn(\"L\")\n",
    "\n",
    "v.drive_forward(5)\n",
    "v.turn(\"L\")\n",
    "\n",
    "v.drive_forward(5)\n",
    "v.turn(\"L\")\n",
    "\n",
    "v.drive_forward(4)\n",
    "v.turn(\"L\")\n",
    "\n",
    "v.drive_forward(4)\n",
    "v.turn(\"L\")\n",
    "\n",
    "v.drive_forward(3)\n",
    "v.turn(\"L\")\n",
    "\n",
    "v.drive_forward(3)\n",
    "v.turn(\"L\")\n",
    "\n",
    "v.drive_forward(2)\n",
    "v.turn(\"L\")\n",
    "\n",
    "v.drive_forward(2)\n",
    "v.turn(\"L\")\n",
    "\n",
    "v.drive_forward(1)\n",
    "v.turn(\"L\")\n",
    "\n",
    "v.drive_forward(1)\n",
    "\n",
    "# show the trajectory. It should look like a spiral\n",
    "v.show_trajectory()\n",
    "\n",
    "# TESTING\n",
    "assert(v.x == 5)\n",
    "assert(v.y == 3)\n",
    "first_5 = [\n",
    "    (0, 0),\n",
    "    (8, 0),\n",
    "    (8, 5),\n",
    "    (3, 5),\n",
    "    (3, 1)\n",
    "]\n",
    "assert(first_5 == v.history[:5])\n",
    "print(\"Nice job! Your vehicle is behaving as expected!\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# TESTING CODE Part 2\n",
    "def test_zig_zag():\n",
    "    v = Vehicle()\n",
    "    for i in range(10):\n",
    "        for _ in range(4):\n",
    "            v.drive_forward(2)\n",
    "            v.turn(\"R\")\n",
    "            v.drive_forward(1)\n",
    "            v.turn(\"L\")\n",
    "        v.drive_forward(10)\n",
    "        v.turn(\"R\")\n",
    "    first_six = [\n",
    "        (0,0),\n",
    "        (2,0),\n",
    "        (2,-1),\n",
    "        (4,-1),\n",
    "        (4,-2),\n",
    "        (6,-2)\n",
    "    ]\n",
    "    v.show_trajectory()\n",
    "    assert(v.x == 14)\n",
    "    assert(v.y == -22)\n",
    "    assert(v.history[:6] == first_six)\n",
    "    print(\"Nice job! Your vehicle passed the zig zag test.\")\n",
    "test_zig_zag()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 下一步是什么？\n",
    "\n",
    "我们希望能够跟踪任何一个行驶方向的车辆轨迹，而不仅仅是四个罗盘方向。"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.5"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
